let app = getApp();
Page({
  ...app.globalData.function,
  data: {
    ...app.globalData.config,
    isShow:true,
    index:{},
    swiperIndex:0,
    currentTab:1,
    istop1:1,
    isLoading: false
  },
 
    onLoad(){
      this.Index().then(res=>{
        if(res.resCode=='9999'){
          this.setData({
            index:res.data
          })
        }
      })

      let isShow= this.getStorage('isShow')
      if(!isShow){
          this.setData({
            isShow:true
          })
      }else{
        this.setData({
          isShow:false
        })
      }
      setTimeout(()=>{
        this.setData({
          isLoading: true // 2秒后，设置为false，页面显示内容
        });
      },1000)

    },

    onShow(){
      this.Index().then(res=>{
        if(res.resCode=='9999'){
          this.setData({
            index:res.data
          })
        }
      })

      var storageData = this.getStorage('user_info');      
      if(storageData){
        this.setData({
          userInfo:storageData
        })
      } 



    },

    //厂家好货
    moredShopGoods(){
      this.router("/pagesShop/goodsall/index?type=2")
    },

    //进入商家
    moreShop(){
      this.router("/pages/nearshop/index","switchTab")
    },

    //好评商品
    moreGoods(){
      this.router("/pagesShop/goodsall/index?type=3")
    },

    //banner 信息跳转
    handleSwiperClick(e){
      let path=e.detail.path
      if(path){
        this.router(path)
      }
    },

    /* 背景随轮播图而改变 */
    swiperChange(e) {
        let currentIndex = e.detail;
        this.setData({
            swiperIndex:currentIndex
        })
    },
        
    //分类信息
    handleMenuClick(e){
      console.log('e',e)
      let url=e.detail.path
      if(this.data.userInfo){
        this.router(url,e.detail.navigate)
      }else{
        this.router("/pages/login/index")
      }      
    },

     // 商品详情
     goDetails:function(events){
      let meetId = events.currentTarget.dataset.posid;
      this.router("/pagesShop/detail/index?id="+meetId)
    },

    

      //拒接
      rejectInfo(){
        this.setData({
          isShow:false 
        })
      },
      //同意
      getUserProfileUrl(){
        this.setData({
          isShow:false 
        })
  
        this.setStorage('isShow',1)     
      },

      privacy_info(){
        this.router('/pages/cash-detail/index?type=privacy');
      },


      //首页跳转
      swichNavtop(e){
        let currentTab= e.currentTarget.dataset.current
        this.setData({
          currentTab
        })
        console.log('currentTab',currentTab)
        if(currentTab==1){
          this.Index().then(res=>{
            if(res.resCode=='9999'){
              this.setData({
                index:res.data,
                istop1:1,
                istop2:0
              })
            }
          })
        }else{

          this.setData({
            istop1:0,
            istop2:1
          })
          
        }
      },

      draw_coupon(){
        this.router('/pages/receive/index')
      }




    

   
})